package com.itheima.d6_singleInstance;

public class Wife {
    //2 定义一个当前类型的静态变量，并私有化
    private static Wife myWife = new Wife("如花", 22);//饿汉


    private String name;
    private int age;

    //1 将构造方法私有化
    private Wife() {

    }


    //3 定义一个静态的方法，用来返回当前的唯一实例
    public static Wife getMyWife() {
        return myWife;
    }


    private Wife(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
